package com.file.system.entity.sort;

import java.io.Serializable;


/**
 * 排序工具
 *
 * @author 靳春晖
 */
public class BaseSort extends BaseSortResult implements ICondition, Serializable {

    //相等
    public static final String EQ = "eq";
    //不等
    public static final String NE = "ne";
    //大于
    public static final String GT = "gt";
    //大于等于
    public static final String GE = "ge";
    //小于
    public static final String LT = "lt";
    //小于等于
    public static final String LE = "le";


    /**
     * 构造方法
     */
    public BaseSort() {

    }

    public BaseSort(String condition) {
        this.setCondition(condition);
    }

    /**
     * 相等
     */
    public static BaseSort eq() {
        BaseSort sort = new BaseSort(BaseSort.EQ);
        return sort;
    }

    /**
     * 不等
     */
    public static BaseSort ne() {
        BaseSort sort = new BaseSort(BaseSort.NE);
        return sort;
    }

    /**
     * 大于
     */
    public static BaseSort gt() {
        BaseSort sort = new BaseSort(BaseSort.GT);
        return sort;
    }

    /**
     * 大于等于
     */
    public static BaseSort ge() {
        BaseSort sort = new BaseSort(BaseSort.GE);
        return sort;
    }

    /**
     * 小于
     */
    public static BaseSort lt() {
        BaseSort sort = new BaseSort(BaseSort.LT);
        return sort;
    }

    /**
     * 小于等于
     */
    public static BaseSort le() {
        BaseSort sort = new BaseSort(BaseSort.LE);
        return sort;
    }


    /**
     * 设置排序条件
     *
     * @param field 条件
     * @param value 值
     * @author 靳春晖
     */
    public BaseSort val(String field, Object value) {
        this.setField(field);
        this.setValue(value);
        return this;
    }


    @Override
    public String getCondition() {
        return super.getCondition();
    }

    @Override
    public Object getSortVal() {
        return super.getValue();
    }

    @Override
    public String getField() {
        return super.getField();
    }
}
